Skip to content

hw-isolation rebase: Added guard, deconfiguration, sparecore #1279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

gcpin
Copy link
Contributor

@gcpin gcpin commented May 7, 2025

1. Add support for guard, deconfiguration and sparecore
2. hw-isolation code relocation to systems_logservices_hwisolation.hpp

Following commits from 1110 are used to create this unified commit

332c310625 - redfish-core: LogServices: Added HardwareIsolation service
36dec57033 - LogServices: HardwareIsolation: LogEntryCollection
3486c6abca - LogServices: HardwareIsolation: Get LogEntry
3d981efb6a - LogServices: HardwareIsolation: Delete LogEntry
11e4cda449 - LogServices: HardwareIsolation: Post ClearLog
723c0fdc70 - redfish-core: Core: Enabled the isolation feature
e4cb16309a - redfish-core: Memory:Enabled the isolation feature
e2158ab941 - Core: Fix, Patch a core into the respective parent processor
4237af36b9 - Hw-Isolation: Deconfiguration type for DIMMs
21582d8c65 - Enabled deconfiguration reason support to the DIMM
558b32f3cc - HW-Isolation: Fix, Don't throw internal error if failed to get error log
2ae01eaf3b - HW-Isolation: Fix, Update State if the Core and DIMM are recovered
84aef9b900 - HW-Isolation: Return an appropriate error if the request is failed.
9ac66c52ac - HW-Isolation: Return ResourceCannotBeDeleted error
f769499d62 - LogService: HW-Isolation: Return an appropriate error
c3839dba53 - redfish-core: Core: Enabled the isolation (aka guard) feature
555fc6ca4c - HW-Isolation: Fix, Use GetAncestors to get the parents id
2cf7c3f830 - HW-Isolation: Fill OriginOfCondition for the TPM and Motherboard
3bd202e472 - LogEntry: HW-Isolation: Removed the Resolved property
10ed0438b8 - HardwareIsolation: Spare core support
5e53b61d8a - HW-Isolation: Fix info PEL AdditionalDataURI
50c9dc3076 - HW-Isolation: Fix Additional Data Uri
7adcfa13f1 - Move getHiddenPropertyValue method to utils
b90a99f053 - Hw-Isolation: Fix eventId HW Deconfiguration page

@jenkins-openbmc-ibm
Copy link

Can one of the admins verify this patch?

@gtmills gtmills requested review from gtmills, baemyung and jeaaustx May 8, 2025 13:58
@gtmills
Copy link
Contributor

gtmills commented May 8, 2025

add to approvelist

asyncResp->res.jsonValue[errorLogPropPath]["@odata.id"] =
boost::urls::format(
"/redfish/v1/Systems/system/LogServices/{}/Entries/{}{}",
logPath, entryID, linkAttachment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is better to be

            asyncResp->res.jsonValue[errorLogPropPath]["@odata.id"] =
                boost::urls::format(
                    "/redfish/v1/Systems/{}/LogServices/{}/Entries/{}{}",
                    BMCWEB_REDFISH_SYSTEM_URI_NAME,
                    logPath, entryID, linkAttachment);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Will push the changes together shortly

@@ -0,0 +1,690 @@
#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License statement

// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors

#pragma once

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Will push the changes together shortly

#include <sdbusplus/message.hpp>
#include <sdbusplus/message/native_types.hpp>
#include <utils/error_log_utils.hpp>
#include <utils/time_utils.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the above 2 include files would need to be (moved to the section L2-L7)

#include "utils/error_log_utils.hpp"
#include "utils/time_utils.hpp"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Will push the changes together shortly

},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better to be done with

 dbus::utility::getSubTreePaths(...)

// the respective hardware is not functional so
// set the state as "Disabled".
asyncResp->res.jsonValue["Status"]["State"] =
"Disabled";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncResp->res.jsonValue["Status"]["State"] = resource::State::Disabled;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Will push the changes together shortly

inline void getObjectEnable(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
const std::string& service, const std::string& path)
{
sdbusplus::asio::getProperty<bool>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

dbus::utility::getProperty<bool>()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
return;
}
sdbusplus::asio::getProperty<std::string>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

dbus::utility::getProperty<bool>()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& entryId, std::function<void(bool hidden)>&& callback)
{
sdbusplus::asio::getProperty<bool>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

dbus::utility::getProperty<bool>()

}

// Get event properties and fill into status conditions
sdbusplus::asio::getAllProperties(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

dbus::utility::getAllProperties

"LogServices/HardwareIsolation"}});
asyncResp->res.jsonValue["[email protected]"] =
logServiceArrayLocal.size();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better like to in the older #1256

            if constexpr (BMCWEB_HW_ISOLATION)
            {
                nlohmann::json& logServiceArrayLocal =
                    asyncResp->res.jsonValue["Members"];
                nlohmann::json::object_t member;
                member["@odata.id"] = boost::urls::format(
                    "redfish/v1/Systems/{}/LogServices/HardwareIsolation",
                    BMCWEB_REDFISH_SYSTEM_URI_NAME);
                logServiceArrayLocal.emplace_back(std::move(member));
                asyncResp->res.jsonValue["[email protected]"] =
                    logServiceArrayLocal.size();
            }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

crow::connections::systemBus->async_method_call(
[asyncResp, resourceObjPath](
const boost::system::error_code& ec,
const dbus::utility::MapperGetAncestorsResponse& ancestors) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this code is being carried forward from prior releases. But in its current format it goes against the OpenBMC coding standards. Specifically using long lambdas. Suggest cleaning this up to move into a named function instead.

(Same comment applies throughout this file and much of this review.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will defer this. Created another JIRA to address moving of lambdas to function. Will attach it to the main conversation

// for parent chassis object id alone, so we should get one
// element.
BMCWEB_LOG_ERROR(
"The given resource object [{}] is contains more than one Chassis as parent so failed return ChassisPowerStateOffRequiredError in the response",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extraneous word: "is"

if (severityVal ==
"xyz.openbmc_project.Logging.Event.SeverityLevel.Critical")
{
asyncResp->res.jsonValue[severityPropPath] = "Critical";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these strings map to generated Redfish enums?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// MessageRegistries
std::vector<std::string> messageArgs{*msgPropVal};

// Fill the "msgPropVal" as reason
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use the utility function fillMessageArgs() instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will also address this as part of the new JIRA

* @brief API used to process the Memory "Enabled" member which is
* patched to do appropriate action.
*
* @param[in] resp - The redfish response to return.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment doesn't match name of parameter

crow::connections::systemBus->async_method_call(
[asyncResp, dbusObjPath,
entryJsonIdx](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& objType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really long lambda. It would be better to put it into a named function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address this in a separate commit. Attached JIRA ticket for reference

}

// Fill the isolated hardware object id along with the Redfish URI
std::string redfishUri =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use std::format() here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

severityString ==
"xyz.openbmc_project.HardwareIsolation.Entry.Type.Spare")
{
entryJson["Severity"] = "OK";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use a generated Redifsh enum?

crow::connections::systemBus->async_method_call(
[asyncResp, entryId,
entryObjPath](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& objType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file also has lots of long lambdas which would benefit the readability to move into named functions per the coding guidelines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address in the next commit. Attached JIRA ticket details for reference

.methods(boost::beast::http::verb::get)(
getSystemHardwareIsolationLogEntryCollection);

BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better for searching the code if the Redfish URI path string was all in a single string. Same comment below.

@gcpin gcpin changed the title WIP: hw-isolation rebase: Added guard, deconfiguration, sparecore hw-isolation rebase: Added guard, deconfiguration, sparecore May 13, 2025
@gtmills
Copy link
Contributor

gtmills commented May 14, 2025

jenkins run tests please

@deepakala-k deepakala-k force-pushed the bmcweb_hwisolation_rebase branch 8 times, most recently from 24457ee to 7512534 Compare May 21, 2025 16:57
Copy link
Contributor

@deepakala-k deepakala-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the comments. I have addressed almost all of them except that ones that include changes to convert the lambdas into named function. Please review it. I will get the JIRA details from my team and attach it shortly. (by our tomorrow morning)

}

// Fill the isolated hardware object id along with the Redfish URI
std::string redfishUri =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
return;
}
sdbusplus::asio::getProperty<std::string>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,82 @@
#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

crow::connections::systemBus->async_method_call(
[asyncResp, resourceObjPath](
const boost::system::error_code& ec,
const dbus::utility::MapperGetAncestorsResponse& ancestors) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will defer this. Created another JIRA to address moving of lambdas to function. Will attach it to the main conversation

},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetObject",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (severityVal ==
"xyz.openbmc_project.Logging.Event.SeverityLevel.Critical")
{
asyncResp->res.jsonValue[severityPropPath] = "Critical";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetObject",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"LogServices/HardwareIsolation"}});
asyncResp->res.jsonValue["[email protected]"] =
logServiceArrayLocal.size();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

crow::connections::systemBus->async_method_call(
[asyncResp, dbusObjPath,
entryJsonIdx](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& objType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address this in a separate commit. Attached JIRA ticket for reference

crow::connections::systemBus->async_method_call(
[asyncResp, entryId,
entryObjPath](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& objType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address in the next commit. Attached JIRA ticket details for reference

@deepakala-k deepakala-k requested review from baemyung and jeaaustx May 21, 2025 17:00
{
getEnabledStatus(asyncResp, service, corePath, intf);
}
#ifdef BMCWEB_ENABLE_HW_ISOLATION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

if constexpr (BMCWEB_HW_ISOLATION)
{
    // Check for the hardware status event
    hw_isolation_utils::getHwIsolationStatus(asyncResp, corePath);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
};

getProcessorPaths(asyncResp, processorId, std::move(callback));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since callback is small, I think it is better to be inlined as a lambda body

getProcessorPaths(asyncResp, processorId, 
          [asyncResp, coreId, enabled](const std::string& cpuPath) {
         // Handle patched Enabled Redfish property
         if (enabled.has_value())
         {
            patchCpuCoreMemberEnabled(asyncResp, cpuPath, coreId, *enabled);
        });

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -179,6 +179,11 @@ void getDbusObject(const std::string& path,
std::function<void(const boost::system::error_code&,
const MapperGetObject&)>&& callback);

void getAncestor(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is matching with "GetAncestors" dbus-call, I think it is better to be named as getAncestors().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Assembly
// GET and
// PATCH
// handler.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge the above comment line L838-L852 into a line and rerun `clang-format-19' to squeeze them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// name,
// object
// path, and
// interface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge the comment of lines L333-L340 (and then rerun clang-format-19)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

BMCWEB_ROUTE(
app,
"/redfish/v1/Systems/<str>/LogServices/HardwareIsolation/Actions/LogService.ClearLog/")
.privileges(redfish::privileges::postLogService)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be

        .privileges(redfish::privileges::
                        postLogServiceSubOverComputerSystemLogServiceCollection)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -224,6 +224,22 @@ void getDbusObject(const std::string& path,
"xyz.openbmc_project.ObjectMapper", "GetObject", path, interfaces);
}

void getAncestor(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAncestors()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// implemented before
// finding the assembly id
// as per bmcweb Assembly
// design.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also combine the above L787-L793 comment lines

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

```
1. Add support for guard, deconfiguration and sparecore
2. hw-isolation code relocation to systems_logservices_hwisolation.hpp

Following commits from 1110 are used to create this unified commit

332c310 - redfish-core: LogServices: Added HardwareIsolation service
36dec57 - LogServices: HardwareIsolation: LogEntryCollection
3486c6a - LogServices: HardwareIsolation: Get LogEntry
3d981ef - LogServices: HardwareIsolation: Delete LogEntry
11e4cda - LogServices: HardwareIsolation: Post ClearLog
723c0fd - redfish-core: Core: Enabled the isolation feature
e4cb163 - redfish-core: Memory:Enabled the isolation feature
e2158ab - Core: Fix, Patch a core into the respective parent processor
4237af3 - Hw-Isolation: Deconfiguration type for DIMMs
21582d8 - Enabled deconfiguration reason support to the DIMM
558b32f - HW-Isolation: Fix, Don't throw internal error if failed to get error log
2ae01ea - HW-Isolation: Fix, Update State if the Core and DIMM are recovered
84aef9b - HW-Isolation: Return an appropriate error if the request is failed.
9ac66c5 - HW-Isolation: Return ResourceCannotBeDeleted error
f769499 - LogService: HW-Isolation: Return an appropriate error
c3839db - redfish-core: Core: Enabled the isolation (aka guard) feature
555fc6c - HW-Isolation: Fix, Use GetAncestors to get the parents id
2cf7c3f - HW-Isolation: Fill OriginOfCondition for the TPM and Motherboard
3bd202e - LogEntry: HW-Isolation: Removed the Resolved property
10ed043 - HardwareIsolation: Spare core support
5e53b61 - HW-Isolation: Fix info PEL AdditionalDataURI
50c9dc3 - HW-Isolation: Fix Additional Data Uri
7adcfa1 - Move getHiddenPropertyValue method to utils
b90a99f - Hw-Isolation: Fix eventId HW Deconfiguration page
```

Signed-off-by: Gopichand Paturi <[email protected]>
Co-authored-by: Ramesh Iyyar <[email protected]>
Co-authored-by: deepakala k <[email protected]>
@deepakala-k deepakala-k force-pushed the bmcweb_hwisolation_rebase branch from 7512534 to bcebe75 Compare May 22, 2025 07:38
@deepakala-k deepakala-k requested a review from baemyung May 22, 2025 07:42
@deepakala-k
Copy link
Contributor

Thank you reviewing with close attention. I have addressed all the comments.

Copy link
Contributor

@baemyung baemyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks much better and I think it can go in.
(Later more to be refined and enhanced).

@deepakala-k
Copy link
Contributor

@baemyung I captured all the comments that are yet to be addressed in this JIRA. https://jsw.ibm.com/browse/PFEBMC-4397
Thanks a lot for the quick review.

@rfrandse rfrandse merged commit 7139c83 into ibm-openbmc:1120 May 22, 2025
1 check passed
return;
}

asyncResp->res.jsonValue["Enabled"] = enabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncResp->res.jsonValue["Members"];
nlohmann::json::object_t member;
member["@odata.id"] = boost::urls::format(
"redfish/v1/Systems/{}/LogServices/HardwareIsolation",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://ibm-systems-power.slack.com/archives/C04KG79NAUA/p1747927965504969?thread_ts=1747903373.957939&cid=C04KG79NAUA

The validator fails because of a missing "/" in front of this.

                member["@odata.id"] = boost::urls::format(
                    "/redfish/v1/Systems/{}/LogServices/HardwareIsolation",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants